<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - iris.info - kernel/simulator.cc</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../index.html">directory</a> - <a href="index.html">kernel</a> - simulator.cc</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>iris.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-05-24</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">45</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">66.7 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">30</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : // Implementation of the IAASim Simulator
<span class="lineNum">       2 </span>                : // George F. Riley, Georgia Tech, Summer 2009
<span class="lineNum">       3 </span>                : 
<span class="lineNum">       4 </span>                : #include &quot;simulator.h&quot;
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : int        EventBase::nextUID = 0;
<span class="lineNum">       7 </span><span class="lineCov">              1 : EventSet_t Simulator::events;</span>
<span class="lineNum">       8 </span>                : bool       Simulator::halted = false;
<span class="lineNum">       9 </span>                : double     Simulator::simTime;
<span class="lineNum">      10 </span>                : int        Simulator::rank;
<span class="lineNum">      11 </span>                : int        Simulator::nextComponentID;
<span class="lineNum">      12 </span><span class="lineCov">              1 : ComponentMap_t        Simulator::components;</span>
<span class="lineNum">      13 </span>                : 
<span class="lineNum">      14 </span>                : // Event0Stat is not a template, so we implement it here
<span class="lineNum">      15 </span><span class="lineCov">              1 : void Event0Stat::CallHandler()</span>
<span class="lineNum">      16 </span>                : {
<span class="lineNum">      17 </span><span class="lineCov">              1 :   handler();</span>
<span class="lineNum">      18 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">      19 </span>                : 
<span class="lineNum">      20 </span>                : 
<span class="lineNum">      21 </span><span class="lineCov">              1 : void Simulator::Run()</span>
<span class="lineNum">      22 </span>                : {
<span class="lineNum">      23 </span><span class="lineCov">              1 :   rank=0;</span>
<span class="lineNum">      24 </span><span class="lineCov">       43851288 :   while(!events.empty() &amp;&amp; !halted)</span>
<span class="lineNum">      25 </span>                :     {
<span class="lineNum">      26 </span>                :       EventSet_t::iterator i = events.begin();
<span class="lineNum">      27 </span><span class="lineCov">       43851286 :       EventBase* ev = *i;  // Get the event</span>
<span class="lineNum">      28 </span>                :       // Set the simulation time
<span class="lineNum">      29 </span><span class="lineCov">       43851286 :       simTime = ev-&gt;time;</span>
<span class="lineNum">      30 </span>                :       // Call the event handler
<span class="lineNum">      31 </span><span class="lineCov">       43851286 :       ev-&gt;CallHandler();</span>
<span class="lineNum">      32 </span>                : //      cout &lt;&lt; &quot;\nTime: &quot; &lt;&lt; Simulator::Now() &lt;&lt;&quot; Going to erase event now uid is &quot; &lt;&lt; ev-&gt;uid;
<span class="lineNum">      33 </span>                :       // Remove the event from the pending list
<span class="lineNum">      34 </span><span class="lineCov">       43851286 :       events.erase(i);</span>
<span class="lineNum">      35 </span>                :       // And delete the event
<span class="lineNum">      36 </span><span class="lineCov">       43851286 :       delete ev;</span>
<span class="lineNum">      37 </span>                :     }
<span class="lineNum">      38 </span>                :   
<span class="lineNum">      39 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">      40 </span>                : 
<span class="lineNum">      41 </span><span class="lineCov">              1 : void Simulator::Stop()</span>
<span class="lineNum">      42 </span>                : {
<span class="lineNum">      43 </span><span class="lineCov">              1 :   halted = true;</span>
<span class="lineNum">      44 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">      45 </span>                : 
<span class="lineNum">      46 </span><span class="lineCov">              1 : void Simulator::StopAt(double stopTime)</span>
<span class="lineNum">      47 </span>                : { // code later
<span class="lineNum">      48 </span><span class="lineCov">              1 :   Schedule(stopTime, &amp;Simulator::Stop);</span>
<span class="lineNum">      49 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">      50 </span>                : 
<span class="lineNum">      51 </span><span class="lineCov">       80824001 : double Simulator::Now()</span>
<span class="lineNum">      52 </span>                : {
<span class="lineNum">      53 </span><span class="lineCov">       80824001 :   return simTime;</span>
<span class="lineNum">      54 </span>                : }
<span class="lineNum">      55 </span>                : 
<span class="lineNum">      56 </span><span class="lineNoCov">              0 : bool Simulator::Cancel(EventId&amp; evid)</span>
<span class="lineNum">      57 </span>                : {
<span class="lineNum">      58 </span><span class="lineNoCov">              0 :   EventSet_t::iterator it = events.find(&amp;evid);</span>
<span class="lineNum">      59 </span><span class="lineNoCov">              0 :   if (it == events.end()) return false; // Not found</span>
<span class="lineNum">      60 </span><span class="lineNoCov">              0 :   events.erase(it);                     // Otherwise erase it</span>
<span class="lineNum">      61 </span><span class="lineNoCov">              0 :   return true;</span>
<span class="lineNum">      62 </span>                : }
<span class="lineNum">      63 </span>                : 
<span class="lineNum">      64 </span><span class="lineNoCov">              0 : EventId Simulator::Peek()</span>
<span class="lineNum">      65 </span>                : { // Return eventid for earliest event, but do not remove it
<span class="lineNum">      66 </span>                :   // Event list must not be empty
<span class="lineNum">      67 </span>                :   EventSet_t::iterator it = events.begin();
<span class="lineNum">      68 </span><span class="lineNoCov">              0 :   return EventId((*it)-&gt;time, (*it)-&gt;uid);</span>
<span class="lineNum">      69 </span>                : }
<span class="lineNum">      70 </span>                : 
<span class="lineNum">      71 </span><span class="lineNoCov">              0 : EventBase* Simulator::GetEarliestEvent()</span>
<span class="lineNum">      72 </span>                : {
<span class="lineNum">      73 </span>                :   EventSet_t::iterator it = events.begin();
<span class="lineNum">      74 </span><span class="lineNoCov">              0 :   if (it == events.end()) return 0;</span>
<span class="lineNum">      75 </span><span class="lineNoCov">              0 :   return *it;</span>
<span class="lineNum">      76 </span>                : }
<span class="lineNum">      77 </span>                : 
<span class="lineNum">      78 </span><span class="lineNoCov">              0 : int Simulator::MyRank()</span>
<span class="lineNum">      79 </span>                : {
<span class="lineNum">      80 </span><span class="lineNoCov">              0 :   return rank;</span>
<span class="lineNum">      81 </span>                : 
<span class="lineNum">      82 </span>                : }
<span class="lineNum">      83 </span>                : 
<span class="lineNum">      84 </span>                :   
<span class="lineNum">      85 </span><span class="lineCov">            872 : void Simulator::registerComponent(Component* obj, int lp)</span>
<span class="lineNum">      86 </span>                : {
<span class="lineNum">      87 </span>                :   ComponentDescription* compDesc;
<span class="lineNum">      88 </span><span class="lineCov">            872 :   if(lp==rank)</span>
<span class="lineNum">      89 </span>                :     {
<span class="lineNum">      90 </span><span class="lineCov">           1744 :       compDesc = new ComponentDescription(lp, obj);</span>
<span class="lineNum">      91 </span>                :     }
<span class="lineNum">      92 </span>                :   else
<span class="lineNum">      93 </span>                :     {
<span class="lineNum">      94 </span><span class="lineNoCov">              0 :       compDesc = new ComponentDescription(lp, NULL);</span>
<span class="lineNum">      95 </span>                :     }
<span class="lineNum">      96 </span><span class="lineCov">            872 :   components[nextComponentID]=compDesc;</span>
<span class="lineNum">      97 </span><span class="lineCov">            872 :   obj-&gt;setComponentId(nextComponentID);</span>
<span class="lineNum">      98 </span><span class="lineCov">            872 :   nextComponentID++;</span>
<span class="lineNum">      99 </span><span class="lineCov">            872 : }</span>
<span class="lineNum">     100 </span>                : 
<span class="lineNum">     101 </span><span class="lineNoCov">              0 : ComponentDescription* Simulator::getComponentDesc(int compId)</span>
<span class="lineNum">     102 </span>                : {
<span class="lineNum">     103 </span><span class="lineNoCov">              0 :   return components[compId];</span>
<span class="lineNum">     104 </span><span class="lineCov">              2 : }</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
